﻿@using JinJun.YShow.Model;
@{
    var Spec = ViewBag.Spec as List<Spec>;
    var Product = ViewBag.Product as Product_Spu;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <link href="~/css/shop.css" type="text/css" rel="stylesheet" />
    <link href="~/css/Sellerber.css" type="text/css" rel="stylesheet" />
    <link href="~/css/bkg_ui.css" type="text/css" rel="stylesheet" />
    <link href="~/font/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <script src="~/js/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="~/js/Sellerber.js" type="text/javascript"></script>
    <script src="~/js/jquery.dataTables.min.js"></script>
    <script src="~/js/jquery.dataTables.bootstrap.js"></script>
    <script src="~/js/layer/layer.js" type="text/javascript"></script>
    <script src="~/js/laydate/laydate.js" type="text/javascript"></script>
    <script src="~/js/hsCheckData.js" type="text/javascript"></script>
    <script src="~/js/dist/echarts-all.js" type="text/javascript"></script>
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js" type="text/javascript"></script>
    <script src="js/respond.min.js"></script>
    <script src="js/css3-mediaqueries.js"  type="text/javascript"></script>
      <![endif]-->
    <title>添加产品</title>
</head>

<body>
    <div class="margin inside_pages clearfix">
        <div class="add_style clearfix relative">
            <!--品牌展示 当通过品牌管理添加产品是显示该-->
            <div class="Brand_title">
                <div class="Brand_img"><img src="product_img/logo/458.jpg" /><h3>卡姿兰</h3></div>
            </div>
            <ul>
                <li class="clearfix"><label class="label_name col-xs-1"><i>*</i>商品名称：&nbsp;&nbsp;</label><div class="Add_content col-xs-11"><input name="" value="@Product.Name" id="Name" type="text" class="col-xs-6" readonly/></div></li>
                <li class="clearfix">
                    <label class="label_name col-xs-1"><i>*</i>选择规格：&nbsp;&nbsp;</label><div class="Add_content col-xs-11">
                        <select id="Spec">
                            @for (int i = 0; i < Spec.Count; i++)
                            {
                                <option value="@Spec[i].Id">@Spec[i].Spec_Name</option>
                            }
                        </select>
                        <select id="Spec_Value">
                        </select>
                    </div>
                </li>
                <li class="clearfix">
                    <div class="col-xs-4">
                        <input type="hidden" value="@Product.Id" id="Id"/>
                        <label class="label_name col-xs-3"><i>*</i>库存数量：&nbsp;&nbsp;</label>
                        <div class="Add_content col-xs-9">
                            <input name="" id="Stock" type="text" class="col-xs-7" /><em class="Prompt">件</em>
                        </div>
                    </div>
                </li>
            </ul>
            <div class="Button_operation btn_width">
                <input class="btn button_btn bg-deep-blue" id="commit" type="button" value="保存并提交" />
                <button class="btn button_btn bg-orange" type="button">保存草稿</button>
                <button class="btn button_btn bg-gray" type="button">取消添加</button>
            </div>
        </div>
    </div>
</body>
</html>
<!--复文本编辑框-->
<script type="text/javascript" charset="utf-8" src="~/js/utf8-jsp/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="~/js/utf8-jsp/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="~/js/utf8-jsp/lang/zh-cn/zh-cn.js"></script>
<script>
    $(function () {
        //绑定二级菜单
        var data = {};
        data.Id = $("#Spec").val();
        var Parent = $("#Spec_Value");
        $.ajax({
            url: "/Product/GetSpecValue",
            type: "post",
            data: data,
            success: function (result) {
                var myHTML = "";
                Parent.html("");//赋值之前先清空
                $.each(result, function (i, data) {
                    myHTML += "<option value=" + data.Id + ">" + data.Spec_value1 + "</option>";

                });
                Parent.append(myHTML);
            }
        });

        $("#Spec").change(function () {
            //绑定二级菜单
            var data = {};
            data.Id = $("#Spec").val();
            var Parent = $("#Spec_Value");
            $.ajax({
                url: "/Product/GetSpecValue",
                type: "post",
                data: data,
                success: function (result) {
                    var myHTML = "";
                    Parent.html("");//赋值之前先清空
                    $.each(result, function (i, data) {
                        myHTML += "<option value=" + data.Id + ">" + data.Spec_value1 + "</option>";

                    });
                    Parent.append(myHTML);
                }
            });
        });

        $("#commit").click(function () {
            var data = {};
            data.ProductId = $("#Id").val();
            data.Stock = $("#Stock").val();
            data.Spec_Id = $("#Spec").val();
            data.Spec_Value_Id = $("#Spec_Value").val();
            $.ajax({
                url: "/Product/EditStock",
                type: "post",
                data: data,
                success: function (result) {
                    if (result.Success) {
                        layer.msg('设置成功！',
                            {
                                icon: 1,
                                time: 2000,
                                shade: 0.2
                            }, function () {
                                window.location.reload(true);
                            });
                    }
                    else {
                        layer.msg('设置失败！',
                            {
                                icon: 1,
                                time: 2000,
                                shade: 0.2
                            });
                    }
                }
            });
        });
    });



    /*********滚动事件*********/
    $("body").niceScroll({
        cursorcolor: "#888888",
        cursoropacitymax: 1,
        touchbehavior: false,
        cursorwidth: "5px",
        cursorborder: "0",
        cursorborderradius: "5px"
    });
</script>
